#!/usr/bin/env python
# encoding: utf-8
# @author: Lin Han
# @contact: voldemort22@126.com
# @file: main.py
# @time: 2021/3/18 14:11
# @desc:
import os

# import sys
#
# sys.path.append(os.path.abspath(os.path.dirname(__file__)))

from fastapi import FastAPI

from application.data_board.app import data_board_router
from application.factory_standard.app import factory_standard_router
from application.relation.app import relation_router
from application.scene.app import scene_router
from application.history_clamp.app import history_clamp_router
from application.message_queue.app import message_queue_router
from application.standard_clamp.app import standard_clamp_router
from application.standard_part.app import standard_part_router
from application.history_part.app import history_part_router
from application.parameter_model.app import parameter_model_router
from application.do_drawing.app import do_drawing_router

app = FastAPI()

app.include_router(history_clamp_router)
app.include_router(history_part_router)
app.include_router(standard_clamp_router)
app.include_router(standard_part_router)
app.include_router(parameter_model_router)
app.include_router(scene_router)
app.include_router(message_queue_router)
app.include_router(relation_router)
app.include_router(factory_standard_router)
app.include_router(data_board_router)
app.include_router(do_drawing_router)
# app.include_router(security_router)

if __name__ == '__main__':
    import uvicorn
    from multiprocessing import cpu_count

    module = os.path.basename(__file__).split(".")[0]
    available_cpu = int(cpu_count() * 3 / 4)
    uvicorn.run(f'{module}:app', host="0.0.0.0", port=18000, workers=available_cpu)
